<?php
/**
 * Created by PhpStorm.
 * User: Kau
 * Date: 2018/3/21
 * Time: 23:12
 */
namespace app\admin\controller;

use think\Controller;
use think\Facade;
use think\Model;
use think\Request;

abstract class Base extends Controller
{
    public function status(Request $request)
    {
        $data = $request->param();
        if (empty($data['id']))
        {
            $this->error('id不合法');
        }
        if (!is_numeric($data['status']))
        {
            $this->error('状态不合法');
        }
        // 获取控制器
        $model = $request->controller();
        $res = model($model)->save(['status' => $data['status']], ['id' => $data['id']]);
        if ($res)
        {
            $this->success('更新成功');
        }
        else
        {
            $this->error('更新失败');
        }
    }

    // TODO:排序
}